﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Syncfusion.Windows.Forms;

namespace Omega.Editor.Forms
{
    public partial class FrmNewProject : Office2007Form
    {

        struct projInfo
        {
            public String Name;
            public String Path;
            public Classes.Language Lang;
        }

        List<projInfo> pInfos = new List<projInfo>();
        projInfo op;


        public FrmNewProject()
        {
            InitializeComponent();
        }

        private void splitButton2_Click(object sender, EventArgs e)
        {

        }

        public Classes.Projeto.Info OpenDialog()
        {
            this.LoadRecentProjects();
            this.ShowDialog();
            return null;
        }

        private void buttonAdv2_Click(object sender, EventArgs e)
        {

        }


        private void LoadRecentProjects()
        {
       

            String _projects = Classes.Registro.Ler("Omega\\RecentProjects\\", "Projects", null);

            if (_projects == null)
                return;

            String[] Projects = _projects.Split(";".ToArray());

            if (Projects.Length == 0)
                return;

            foreach (string prj in Projects)
            {
                if (prj.Trim() == String.Empty)
                    continue;

                string[] info = prj.Split("|".ToArray());

                projInfo p = new projInfo();
                p.Name = info[0];
                p.Path = info[1];

                p.Lang = (Classes.Language)int.Parse(info[2]);

                ListViewItem oitem = new ListViewItem(new[] { p.Name, p.Path }, (int)p.Lang);
              
                pInfos.Add(p);

                if (!File.Exists(p.Path + "\\Project.OmPrg"))
                    oitem.ForeColor = Color.Red;

                this.LvProjetosRecentes.Items.Add(oitem);

            }




        }

        

        private void FrmNewProject_Load(object sender, EventArgs e)
        {
        
        }

        private void LvProjetosRecentes_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.BtnAbrir.Enabled = true;
        }

        private void rButtonSIcons_CheckChanged(object sender, EventArgs e)
        {
            this.LvProjetosRecentes.View = View.SmallIcon ;
        }

        private void rButtonLista_CheckChanged(object sender, EventArgs e)
        {
            this.LvProjetosRecentes.View = View.List;
        }

        private void rButtonLIcons_CheckChanged(object sender, EventArgs e)
        {
            this.LvProjetosRecentes.View = View.LargeIcon;
        }

        private void rButtonDetalhes_CheckChanged(object sender, EventArgs e)
        {
            this.LvProjetosRecentes.View = View.Details;
        }
    }
}
